package components;

import bean.GuaMap;
import cn.hutool.core.io.resource.ResourceUtil;
import com.alibaba.fastjson.JSON;

import java.io.IOException;
import java.util.Map;

public class DataFactory {
    private static final DataFactory instance = new DataFactory();
    private DataFactory() {}
    public static DataFactory getInstance() {
        return instance;
    }

    private Map<String, GuaMap.Gua> guaMap;

    public Map<String, GuaMap.Gua> getGuaMap() {
        return guaMap;
    }

    public void init() throws IOException {
        GuaMap guaMapObject = JSON.parseObject(
                ResourceUtil.getStream("bagua.json"), GuaMap.class);
        this.guaMap = guaMapObject.getMap();
    }
}
